package com.smart.platform.config;

import com.smart.platform.interceprot.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration //拦截器的配置类 其中引入了拦截器对象
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加不需要拦截的路径
        String[] urls = new String[]{
                "/Teachers/login",
                "/Teachers/logout",
                "/Students/login",
                "/Students/logout"
        };

        //List<String> list = new ArrayList<>(Arrays.asList(urls));

        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns(urls);
        //拦截所有路径 除了 登录路径
    }
}
